using UnityEngine;

public class EnemyAnimationTriggers : MonoBehaviour
{
    private Enemy enemy => GetComponentInParent<Enemy>();

    private void AnimationTrigger() => enemy.StateMachine.CurrentState.AnimationFinishTrigger();

    private void SpeicalAttackTrigger()
    {
        enemy.SpeicalAttackTrigger();
    }

    private void AttackTrigger()
    {
        Collider2D player = Physics2D.OverlapCircle(enemy.AttackPoint.position, enemy.attackCheckRadius, enemy.PlayerLayer);
        if (!player || !player.TryGetComponent(out PlayerStats playerStats)) return;
        enemy.Stats.DoDamage(playerStats);
    }

    private void OpenCounterWindow() => enemy.OpenCounterAttackWindow();

    private void CloseCounterWindow() => enemy.CloseCounterAttackWindow();
}